/*
 * @project-name workflow
 * @Description: 
 * @author lenovo whr2349
 * @date 2021/6/30 13:40
 * @file organization
*/
"use strict";

const Controller = require('../core/BaseController')

class OrganizationController extends Controller {

    async index() {
        const { ctx } = this;
        const param = ctx.request.query;
        const result = await ctx.service.organization.index(param.currentPage, param.pageSize)
        const total = await ctx.model.Organization.countDocuments()
        super.success({
            data: result,
            msg: "成功",
            total
        })
    }
    async treeIndex() {
        const { ctx } = this;
        const param = ctx.request.query;
        const result = await ctx.service.organization.treeIndex(param.currentPage, param.pageSize, { sort: 1 })
        const total = await ctx.model.Organization.countDocuments()
        super.success({
            data: result,
            msg: "成功",
            total
        })
    }
    async create() {
        const { ctx } = this;
        const param = ctx.request.body.data
        const result = await ctx.service.organization.findByIdAndUpdate(param)
        super.success({
            data: result,
            msg: "成功"
        })
    }
}

module.exports = OrganizationController;